home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / include / glib-2.0 / glib / goption.h < prev    next >
Encoding:
C/C++ Source or Header  |  2006-04-25  |  4.7 KB  |  145 lines

  1. /* goption.h - Option parser
  2.  *
  3.  *  Copyright (C) 2004  Anders Carlsson <andersca@gnome.org>
  4.  *
  5.  * This library is free software; you can redistribute it and/or
  6.  * modify it under the terms of the GNU Library General Public
  7.  * License as published by the Free Software Foundation; either
  8.  * version 2 of the License, or (at your option) any later version.
  9.  *
  10.  * This library is distributed in the hope that it will be useful,
  11.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.     See the GNU
  13.  * Library General Public License for more details.
  14.  *
  15.  * You should have received a copy of the GNU Library General Public
  16.  * License along with this library; if not, write to the
  17.  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  18.  * Boston, MA 02111-1307, USA.
  19.  */
  20.  
  21. #ifndef __G_OPTION_H__
  22. #define __G_OPTION_H__
  23.  
  24. #include <glib/gerror.h>
  25. #include <glib/gquark.h>
  26.  
  27. G_BEGIN_DECLS
  28.  
  29. typedef struct _GOptionContext GOptionContext;
  30. typedef struct _GOptionGroup   GOptionGroup;
  31. typedef struct _GOptionEntry   GOptionEntry;
  32.  
  33. typedef enum
  34. {
  35.   G_OPTION_FLAG_HIDDEN        = 1 << 0,
  36.   G_OPTION_FLAG_IN_MAIN        = 1 << 1,
  37.   G_OPTION_FLAG_REVERSE        = 1 << 2,
  38.   G_OPTION_FLAG_NO_ARG        = 1 << 3,
  39.   G_OPTION_FLAG_FILENAME    = 1 << 4,
  40.   G_OPTION_FLAG_OPTIONAL_ARG    = 1 << 5,
  41.   G_OPTION_FLAG_NOALIAS            = 1 << 6
  42. } GOptionFlags;
  43.  
  44. typedef enum
  45. {
  46.   G_OPTION_ARG_NONE,
  47.   G_OPTION_ARG_STRING,
  48.   G_OPTION_ARG_INT,
  49.   G_OPTION_ARG_CALLBACK,
  50.   G_OPTION_ARG_FILENAME,
  51.   G_OPTION_ARG_STRING_ARRAY,
  52.   G_OPTION_ARG_FILENAME_ARRAY
  53. } GOptionArg;
  54.  
  55. typedef gboolean (*GOptionArgFunc) (const gchar    *option_name,
  56.                     const gchar    *value,
  57.                     gpointer        data,
  58.                     GError        **error);
  59.  
  60. typedef gboolean (*GOptionParseFunc) (GOptionContext *context,
  61.                       GOptionGroup   *group,
  62.                       gpointer          data,
  63.                       GError        **error);
  64.  
  65. typedef void (*GOptionErrorFunc) (GOptionContext *context,
  66.                   GOptionGroup   *group,
  67.                   gpointer        data,
  68.                   GError        **error);
  69.  
  70. #define G_OPTION_ERROR (g_option_error_quark ())
  71.  
  72. typedef enum
  73. {
  74.   G_OPTION_ERROR_UNKNOWN_OPTION,
  75.   G_OPTION_ERROR_BAD_VALUE,
  76.   G_OPTION_ERROR_FAILED
  77. } GOptionError;
  78.  
  79. GQuark g_option_error_quark (void);
  80.  
  81.  
  82. struct _GOptionEntry
  83. {
  84.   const gchar *long_name;
  85.   gchar        short_name;
  86.   gint         flags;
  87.  
  88.   GOptionArg   arg;
  89.   gpointer     arg_data;
  90.   
  91.   const gchar *description;
  92.   const gchar *arg_description;
  93. };
  94.  
  95. #define G_OPTION_REMAINING ""
  96.  
  97. GOptionContext *g_option_context_new              (const gchar         *parameter_string);
  98. void            g_option_context_free             (GOptionContext      *context);
  99. void        g_option_context_set_help_enabled (GOptionContext      *context,
  100.                            gboolean        help_enabled);
  101. gboolean    g_option_context_get_help_enabled (GOptionContext      *context);
  102. void        g_option_context_set_ignore_unknown_options (GOptionContext *context,
  103.                                  gboolean         ignore_unknown);
  104. gboolean        g_option_context_get_ignore_unknown_options (GOptionContext *context);
  105.  
  106. void            g_option_context_add_main_entries (GOptionContext      *context,
  107.                            const GOptionEntry  *entries,
  108.                            const gchar         *translation_domain);
  109. gboolean        g_option_context_parse            (GOptionContext      *context,
  110.                            gint                *argc,
  111.                            gchar             ***argv,
  112.                            GError             **error);
  113.  
  114. void          g_option_context_add_group      (GOptionContext *context,
  115.                            GOptionGroup   *group);
  116. void          g_option_context_set_main_group (GOptionContext *context,
  117.                            GOptionGroup   *group);
  118. GOptionGroup *g_option_context_get_main_group (GOptionContext *context);
  119.  
  120.  
  121. GOptionGroup *g_option_group_new                    (const gchar        *name,
  122.                              const gchar        *description,
  123.                              const gchar        *help_description,
  124.                              gpointer            user_data,
  125.                              GDestroyNotify      destroy);
  126. void          g_option_group_set_parse_hooks        (GOptionGroup       *group,
  127.                              GOptionParseFunc    pre_parse_func,
  128.                              GOptionParseFunc     post_parse_func);
  129. void          g_option_group_set_error_hook        (GOptionGroup       *group,
  130.                              GOptionErrorFunc     error_func);
  131. void          g_option_group_free                   (GOptionGroup       *group);
  132. void          g_option_group_add_entries            (GOptionGroup       *group,
  133.                              const GOptionEntry *entries);
  134. void          g_option_group_set_translate_func     (GOptionGroup       *group,
  135.                              GTranslateFunc      func,
  136.                              gpointer            data,
  137.                              GDestroyNotify      destroy_notify);
  138. void          g_option_group_set_translation_domain (GOptionGroup       *group,
  139.                              const gchar        *domain);
  140.  
  141.  
  142. G_END_DECLS
  143.  
  144. #endif /* __G_OPTION_H__ */
  145.